package com.yq.day24;


import com.sun.deploy.nativesandbox.NativeSandboxOutputStream;

import java.io.*;

/**
 * @author 3307235355@qq.com
 * @since 2022/06/24 08:34
 */
public class Demo01 {
    public static void main(String[] args) throws IOException {
        FileInputStream in = new FileInputStream("a.txt");
        FileOutputStream out1 = new FileOutputStream("b.txt");
        FileOutputStream out2 = new FileOutputStream("c.txt");
        copyFile(in , out1);
        copyFile(in , out2);
        in.close();
        out1.close();
        out2.close();
    }

    private static void copyFile(InputStream in, OutputStream out) throws IOException {
        int readCount;
        byte[] bytes = new byte[1024];
        while((readCount = in.read(bytes)) !=-1) {
            out.write(bytes, 0, readCount);
        }

    }
}
